using System;
using System.Drawing;
using System.Collections;
using System.ComponentModel;
using System.Windows.Forms;
using pixolut.BizBlox;

namespace BizBloxCSExamples
{
	/// <summary>
	/// Summary description for Form1.
	/// </summary>
	public class Form1 : System.Windows.Forms.Form
	{
		private System.Windows.Forms.MainMenu mainMenu1;
		internal System.Windows.Forms.TabControl TabControl1;
		internal System.Windows.Forms.TabPage tpStepOne;
		internal System.Windows.Forms.Label Label17;
		internal System.Windows.Forms.Label Label11;
		internal System.Windows.Forms.ListView lvStudents;
		internal System.Windows.Forms.Button btLoadStudents;
		internal System.Windows.Forms.TabPage tpStepTwo;
		internal System.Windows.Forms.Label Label14;
		internal System.Windows.Forms.ListView lvSearchStudents;
		internal System.Windows.Forms.NumericUpDown numAgeUpper;
		internal System.Windows.Forms.NumericUpDown numAgeLower;
		internal System.Windows.Forms.Label label6;
		internal System.Windows.Forms.Label label4;
		internal System.Windows.Forms.TextBox txSearchByEmail;
		internal System.Windows.Forms.Label label3;
		internal System.Windows.Forms.Label label2;
		internal System.Windows.Forms.Button btSearchStudents;
		internal System.Windows.Forms.Label Label1;
		internal System.Windows.Forms.TextBox txSearchTermStudents;
		internal System.Windows.Forms.TabPage tpStepThree;
		internal System.Windows.Forms.Label Label15;
		internal System.Windows.Forms.Label Label5;
		internal System.Windows.Forms.GroupBox GroupBox1;
		internal System.Windows.Forms.Label Label8;
		internal System.Windows.Forms.TextBox txFoodPrice;
		internal System.Windows.Forms.Label Label10;
		internal System.Windows.Forms.Button btSaveFood;
		internal System.Windows.Forms.TextBox txFoodName;
		internal System.Windows.Forms.Button btDeleteFood;
		internal System.Windows.Forms.TabPage tpStepFour;
		internal System.Windows.Forms.Label Label16;
		internal System.Windows.Forms.TextBox txStepFourEmail;
		internal System.Windows.Forms.NumericUpDown numFoodPriceUpper;
		internal System.Windows.Forms.NumericUpDown numFoodPriceLower;
		internal System.Windows.Forms.Label Label7;
		internal System.Windows.Forms.Label Label9;
		internal System.Windows.Forms.ListView lvLunchOrders;
		internal System.Windows.Forms.Label Label12;
		internal System.Windows.Forms.Button btSearchLunchOrders;
		internal System.Windows.Forms.Label Label13;
		internal System.Windows.Forms.ColumnHeader chName;
		internal System.Windows.Forms.ColumnHeader chEmail;
		internal System.Windows.Forms.ColumnHeader chAge;
		internal System.Windows.Forms.ColumnHeader ColumnHeader1;
		internal System.Windows.Forms.ColumnHeader ColumnHeader2;
		internal System.Windows.Forms.ColumnHeader ColumnHeader3;
		internal System.Windows.Forms.ColumnHeader chLunchOrderDate;
		internal System.Windows.Forms.ColumnHeader chLunchOrderStudent;
		internal System.Windows.Forms.ColumnHeader cbLunchOrderEmail;
		internal System.Windows.Forms.ColumnHeader chLunchOrderFood;
		internal System.Windows.Forms.ColumnHeader chLunchOrderQuantity;
		internal System.Windows.Forms.ColumnHeader chLunchOrderFoodPrice;
		internal System.Windows.Forms.ColumnHeader chLunchOrderTotal;
		private System.Windows.Forms.ComboBox cbFood;
		private System.Windows.Forms.MenuItem mnuTools;
		private System.Windows.Forms.MenuItem mnuResetData;
		private System.Windows.Forms.MenuItem mnuHelp;
		private System.Windows.Forms.MenuItem mnuAbout;
		/// <summary>
		/// Required designer variable.
		/// </summary>
		private System.ComponentModel.Container components = null;

		public Form1()
		{
			//
			// Required for Windows Form Designer support
			//
			InitializeComponent();

			//
			// TODO: Add any constructor code after InitializeComponent call
			//
			setupData();
		}

		/// <summary>
		/// Clean up any resources being used.
		/// </summary>
		protected override void Dispose( bool disposing )
		{
			if( disposing )
			{
				if(components != null)
				{
					components.Dispose();
				}
			}
			base.Dispose( disposing );
		}

		#region Windows Form Designer generated code
		/// <summary>
		/// Required method for Designer support - do not modify
		/// the contents of this method with the code editor.
		/// </summary>
		private void InitializeComponent()
		{
			System.Resources.ResourceManager resources = new System.Resources.ResourceManager(typeof(Form1));
			this.mainMenu1 = new System.Windows.Forms.MainMenu();
			this.mnuTools = new System.Windows.Forms.MenuItem();
			this.mnuResetData = new System.Windows.Forms.MenuItem();
			this.mnuHelp = new System.Windows.Forms.MenuItem();
			this.mnuAbout = new System.Windows.Forms.MenuItem();
			this.TabControl1 = new System.Windows.Forms.TabControl();
			this.tpStepOne = new System.Windows.Forms.TabPage();
			this.Label17 = new System.Windows.Forms.Label();
			this.Label11 = new System.Windows.Forms.Label();
			this.lvStudents = new System.Windows.Forms.ListView();
			this.chName = new System.Windows.Forms.ColumnHeader();
			this.chEmail = new System.Windows.Forms.ColumnHeader();
			this.chAge = new System.Windows.Forms.ColumnHeader();
			this.btLoadStudents = new System.Windows.Forms.Button();
			this.tpStepTwo = new System.Windows.Forms.TabPage();
			this.Label14 = new System.Windows.Forms.Label();
			this.lvSearchStudents = new System.Windows.Forms.ListView();
			this.ColumnHeader1 = new System.Windows.Forms.ColumnHeader();
			this.ColumnHeader2 = new System.Windows.Forms.ColumnHeader();
			this.ColumnHeader3 = new System.Windows.Forms.ColumnHeader();
			this.numAgeUpper = new System.Windows.Forms.NumericUpDown();
			this.numAgeLower = new System.Windows.Forms.NumericUpDown();
			this.label6 = new System.Windows.Forms.Label();
			this.label4 = new System.Windows.Forms.Label();
			this.txSearchByEmail = new System.Windows.Forms.TextBox();
			this.label3 = new System.Windows.Forms.Label();
			this.label2 = new System.Windows.Forms.Label();
			this.btSearchStudents = new System.Windows.Forms.Button();
			this.Label1 = new System.Windows.Forms.Label();
			this.txSearchTermStudents = new System.Windows.Forms.TextBox();
			this.tpStepThree = new System.Windows.Forms.TabPage();
			this.cbFood = new System.Windows.Forms.ComboBox();
			this.Label15 = new System.Windows.Forms.Label();
			this.Label5 = new System.Windows.Forms.Label();
			this.GroupBox1 = new System.Windows.Forms.GroupBox();
			this.Label8 = new System.Windows.Forms.Label();
			this.txFoodPrice = new System.Windows.Forms.TextBox();
			this.Label10 = new System.Windows.Forms.Label();
			this.btSaveFood = new System.Windows.Forms.Button();
			this.txFoodName = new System.Windows.Forms.TextBox();
			this.btDeleteFood = new System.Windows.Forms.Button();
			this.tpStepFour = new System.Windows.Forms.TabPage();
			this.Label16 = new System.Windows.Forms.Label();
			this.txStepFourEmail = new System.Windows.Forms.TextBox();
			this.numFoodPriceUpper = new System.Windows.Forms.NumericUpDown();
			this.numFoodPriceLower = new System.Windows.Forms.NumericUpDown();
			this.Label7 = new System.Windows.Forms.Label();
			this.Label9 = new System.Windows.Forms.Label();
			this.lvLunchOrders = new System.Windows.Forms.ListView();
			this.chLunchOrderDate = new System.Windows.Forms.ColumnHeader();
			this.chLunchOrderStudent = new System.Windows.Forms.ColumnHeader();
			this.cbLunchOrderEmail = new System.Windows.Forms.ColumnHeader();
			this.chLunchOrderFood = new System.Windows.Forms.ColumnHeader();
			this.chLunchOrderQuantity = new System.Windows.Forms.ColumnHeader();
			this.chLunchOrderFoodPrice = new System.Windows.Forms.ColumnHeader();
			this.chLunchOrderTotal = new System.Windows.Forms.ColumnHeader();
			this.Label12 = new System.Windows.Forms.Label();
			this.btSearchLunchOrders = new System.Windows.Forms.Button();
			this.Label13 = new System.Windows.Forms.Label();
			this.TabControl1.SuspendLayout();
			this.tpStepOne.SuspendLayout();
			this.tpStepTwo.SuspendLayout();
			((System.ComponentModel.ISupportInitialize)(this.numAgeUpper)).BeginInit();
			((System.ComponentModel.ISupportInitialize)(this.numAgeLower)).BeginInit();
			this.tpStepThree.SuspendLayout();
			this.GroupBox1.SuspendLayout();
			this.tpStepFour.SuspendLayout();
			((System.ComponentModel.ISupportInitialize)(this.numFoodPriceUpper)).BeginInit();
			((System.ComponentModel.ISupportInitialize)(this.numFoodPriceLower)).BeginInit();
			this.SuspendLayout();
			// 
			// mainMenu1
			// 
			this.mainMenu1.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
																					  this.mnuTools,
																					  this.mnuHelp});
			// 
			// mnuTools
			// 
			this.mnuTools.Index = 0;
			this.mnuTools.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
																					 this.mnuResetData});
			this.mnuTools.Text = "Tools";
			// 
			// mnuResetData
			// 
			this.mnuResetData.Index = 0;
			this.mnuResetData.Text = "Reset Data";
			this.mnuResetData.Click += new System.EventHandler(this.mnuResetData_Click);
			// 
			// mnuHelp
			// 
			this.mnuHelp.Index = 1;
			this.mnuHelp.MenuItems.AddRange(new System.Windows.Forms.MenuItem[] {
																					this.mnuAbout});
			this.mnuHelp.Text = "Help";
			// 
			// mnuAbout
			// 
			this.mnuAbout.Index = 0;
			this.mnuAbout.Text = "About";
			this.mnuAbout.Click += new System.EventHandler(this.mnuAbout_Click);
			// 
			// TabControl1
			// 
			this.TabControl1.Controls.Add(this.tpStepOne);
			this.TabControl1.Controls.Add(this.tpStepTwo);
			this.TabControl1.Controls.Add(this.tpStepThree);
			this.TabControl1.Controls.Add(this.tpStepFour);
			this.TabControl1.Dock = System.Windows.Forms.DockStyle.Fill;
			this.TabControl1.Location = new System.Drawing.Point(0, 0);
			this.TabControl1.Name = "TabControl1";
			this.TabControl1.SelectedIndex = 0;
			this.TabControl1.Size = new System.Drawing.Size(560, 537);
			this.TabControl1.TabIndex = 5;
			// 
			// tpStepOne
			// 
			this.tpStepOne.Controls.Add(this.Label17);
			this.tpStepOne.Controls.Add(this.Label11);
			this.tpStepOne.Controls.Add(this.lvStudents);
			this.tpStepOne.Controls.Add(this.btLoadStudents);
			this.tpStepOne.Location = new System.Drawing.Point(4, 22);
			this.tpStepOne.Name = "tpStepOne";
			this.tpStepOne.Size = new System.Drawing.Size(552, 511);
			this.tpStepOne.TabIndex = 0;
			this.tpStepOne.Text = "Simple Binding";
			// 
			// Label17
			// 
			this.Label17.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
			this.Label17.Location = new System.Drawing.Point(12, 68);
			this.Label17.Name = "Label17";
			this.Label17.Size = new System.Drawing.Size(144, 16);
			this.Label17.TabIndex = 32;
			this.Label17.Text = "Load Students";
			// 
			// Label11
			// 
			this.Label11.BackColor = System.Drawing.Color.LightSteelBlue;
			this.Label11.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
			this.Label11.ForeColor = System.Drawing.Color.Navy;
			this.Label11.Location = new System.Drawing.Point(12, 12);
			this.Label11.Name = "Label11";
			this.Label11.Size = new System.Drawing.Size(528, 40);
			this.Label11.TabIndex = 31;
			this.Label11.Text = "Example 1. This example demonstrates the most simple type of binding. Click \'Load" +
				" Students\' to Find All students in the database, and load their details into the" +
				" ListBox.";
			this.Label11.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
			// 
			// lvStudents
			// 
			this.lvStudents.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] {
																						 this.chName,
																						 this.chEmail,
																						 this.chAge});
			this.lvStudents.Location = new System.Drawing.Point(12, 128);
			this.lvStudents.Name = "lvStudents";
			this.lvStudents.Size = new System.Drawing.Size(528, 360);
			this.lvStudents.TabIndex = 8;
			this.lvStudents.View = System.Windows.Forms.View.Details;
			// 
			// chName
			// 
			this.chName.Text = "Name";
			this.chName.Width = 147;
			// 
			// chEmail
			// 
			this.chEmail.Text = "Email";
			this.chEmail.Width = 154;
			// 
			// chAge
			// 
			this.chAge.Text = "Age";
			this.chAge.Width = 214;
			// 
			// btLoadStudents
			// 
			this.btLoadStudents.Location = new System.Drawing.Point(12, 92);
			this.btLoadStudents.Name = "btLoadStudents";
			this.btLoadStudents.Size = new System.Drawing.Size(68, 24);
			this.btLoadStudents.TabIndex = 4;
			this.btLoadStudents.Text = "Go";
			this.btLoadStudents.Click += new System.EventHandler(this.btLoadStudents_Click);
			// 
			// tpStepTwo
			// 
			this.tpStepTwo.Controls.Add(this.Label14);
			this.tpStepTwo.Controls.Add(this.lvSearchStudents);
			this.tpStepTwo.Controls.Add(this.numAgeUpper);
			this.tpStepTwo.Controls.Add(this.numAgeLower);
			this.tpStepTwo.Controls.Add(this.label6);
			this.tpStepTwo.Controls.Add(this.label4);
			this.tpStepTwo.Controls.Add(this.txSearchByEmail);
			this.tpStepTwo.Controls.Add(this.label3);
			this.tpStepTwo.Controls.Add(this.label2);
			this.tpStepTwo.Controls.Add(this.btSearchStudents);
			this.tpStepTwo.Controls.Add(this.Label1);
			this.tpStepTwo.Controls.Add(this.txSearchTermStudents);
			this.tpStepTwo.Location = new System.Drawing.Point(4, 22);
			this.tpStepTwo.Name = "tpStepTwo";
			this.tpStepTwo.Size = new System.Drawing.Size(552, 511);
			this.tpStepTwo.TabIndex = 1;
			this.tpStepTwo.Text = "Searching";
			this.tpStepTwo.Visible = false;
			// 
			// Label14
			// 
			this.Label14.BackColor = System.Drawing.Color.LightSteelBlue;
			this.Label14.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
			this.Label14.ForeColor = System.Drawing.Color.Navy;
			this.Label14.Location = new System.Drawing.Point(12, 12);
			this.Label14.Name = "Label14";
			this.Label14.Size = new System.Drawing.Size(528, 40);
			this.Label14.TabIndex = 30;
			this.Label14.Text = "Example 2. This example demonstrates how to use custom Find methods in a DOCollec" +
				"tion to easily search and filter results. Enter some search parameters, and clic" +
				"k Go. The name and email are optional.";
			this.Label14.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
			// 
			// lvSearchStudents
			// 
			this.lvSearchStudents.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] {
																							   this.ColumnHeader1,
																							   this.ColumnHeader2,
																							   this.ColumnHeader3});
			this.lvSearchStudents.Location = new System.Drawing.Point(12, 232);
			this.lvSearchStudents.Name = "lvSearchStudents";
			this.lvSearchStudents.Size = new System.Drawing.Size(528, 260);
			this.lvSearchStudents.TabIndex = 29;
			this.lvSearchStudents.View = System.Windows.Forms.View.Details;
			// 
			// ColumnHeader1
			// 
			this.ColumnHeader1.Text = "Name";
			this.ColumnHeader1.Width = 147;
			// 
			// ColumnHeader2
			// 
			this.ColumnHeader2.Text = "Email";
			this.ColumnHeader2.Width = 154;
			// 
			// ColumnHeader3
			// 
			this.ColumnHeader3.Text = "Age";
			this.ColumnHeader3.Width = 214;
			// 
			// numAgeUpper
			// 
			this.numAgeUpper.Location = new System.Drawing.Point(132, 156);
			this.numAgeUpper.Name = "numAgeUpper";
			this.numAgeUpper.Size = new System.Drawing.Size(48, 20);
			this.numAgeUpper.TabIndex = 28;
			this.numAgeUpper.Value = new System.Decimal(new int[] {
																	  50,
																	  0,
																	  0,
																	  0});
			// 
			// numAgeLower
			// 
			this.numAgeLower.Location = new System.Drawing.Point(56, 156);
			this.numAgeLower.Name = "numAgeLower";
			this.numAgeLower.Size = new System.Drawing.Size(48, 20);
			this.numAgeLower.TabIndex = 27;
			// 
			// label6
			// 
			this.label6.Location = new System.Drawing.Point(108, 160);
			this.label6.Name = "label6";
			this.label6.Size = new System.Drawing.Size(24, 16);
			this.label6.TabIndex = 26;
			this.label6.Text = "to";
			// 
			// label4
			// 
			this.label4.Location = new System.Drawing.Point(8, 124);
			this.label4.Name = "label4";
			this.label4.Size = new System.Drawing.Size(40, 23);
			this.label4.TabIndex = 25;
			this.label4.Text = "Email:";
			this.label4.TextAlign = System.Drawing.ContentAlignment.TopRight;
			// 
			// txSearchByEmail
			// 
			this.txSearchByEmail.Location = new System.Drawing.Point(56, 124);
			this.txSearchByEmail.Name = "txSearchByEmail";
			this.txSearchByEmail.Size = new System.Drawing.Size(176, 20);
			this.txSearchByEmail.TabIndex = 24;
			this.txSearchByEmail.Text = "";
			// 
			// label3
			// 
			this.label3.Location = new System.Drawing.Point(8, 160);
			this.label3.Name = "label3";
			this.label3.Size = new System.Drawing.Size(40, 16);
			this.label3.TabIndex = 23;
			this.label3.Text = "Age:";
			this.label3.TextAlign = System.Drawing.ContentAlignment.TopRight;
			// 
			// label2
			// 
			this.label2.Location = new System.Drawing.Point(8, 92);
			this.label2.Name = "label2";
			this.label2.Size = new System.Drawing.Size(40, 23);
			this.label2.TabIndex = 22;
			this.label2.Text = "Name:";
			this.label2.TextAlign = System.Drawing.ContentAlignment.TopRight;
			// 
			// btSearchStudents
			// 
			this.btSearchStudents.Location = new System.Drawing.Point(12, 192);
			this.btSearchStudents.Name = "btSearchStudents";
			this.btSearchStudents.Size = new System.Drawing.Size(64, 24);
			this.btSearchStudents.TabIndex = 20;
			this.btSearchStudents.Text = "Go";
			this.btSearchStudents.Click += new System.EventHandler(this.btSearchStudents_Click);
			// 
			// Label1
			// 
			this.Label1.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
			this.Label1.Location = new System.Drawing.Point(8, 68);
			this.Label1.Name = "Label1";
			this.Label1.Size = new System.Drawing.Size(144, 16);
			this.Label1.TabIndex = 19;
			this.Label1.Text = "Search Students";
			// 
			// txSearchTermStudents
			// 
			this.txSearchTermStudents.Location = new System.Drawing.Point(56, 92);
			this.txSearchTermStudents.Name = "txSearchTermStudents";
			this.txSearchTermStudents.Size = new System.Drawing.Size(176, 20);
			this.txSearchTermStudents.TabIndex = 18;
			this.txSearchTermStudents.Text = "";
			// 
			// tpStepThree
			// 
			this.tpStepThree.Controls.Add(this.cbFood);
			this.tpStepThree.Controls.Add(this.Label15);
			this.tpStepThree.Controls.Add(this.Label5);
			this.tpStepThree.Controls.Add(this.GroupBox1);
			this.tpStepThree.Location = new System.Drawing.Point(4, 22);
			this.tpStepThree.Name = "tpStepThree";
			this.tpStepThree.Size = new System.Drawing.Size(552, 511);
			this.tpStepThree.TabIndex = 2;
			this.tpStepThree.Text = "Editing";
			this.tpStepThree.Visible = false;
			// 
			// cbFood
			// 
			this.cbFood.ItemHeight = 13;
			this.cbFood.Location = new System.Drawing.Point(16, 96);
			this.cbFood.Name = "cbFood";
			this.cbFood.Size = new System.Drawing.Size(240, 21);
			this.cbFood.TabIndex = 32;
			this.cbFood.SelectedIndexChanged += new System.EventHandler(this.cbFood_SelectedIndexChanged);
			// 
			// Label15
			// 
			this.Label15.BackColor = System.Drawing.Color.LightSteelBlue;
			this.Label15.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
			this.Label15.ForeColor = System.Drawing.Color.Navy;
			this.Label15.Location = new System.Drawing.Point(12, 12);
			this.Label15.Name = "Label15";
			this.Label15.Size = new System.Drawing.Size(528, 40);
			this.Label15.TabIndex = 31;
			this.Label15.Text = "Example 3. This example demonstrates three concepts: 1. How to bind data to a Con" +
				"trol (the Food ComboBox), 2. How to add, edit and update data, 3. How to delete " +
				"data.";
			this.Label15.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
			// 
			// Label5
			// 
			this.Label5.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
			this.Label5.Location = new System.Drawing.Point(16, 68);
			this.Label5.Name = "Label5";
			this.Label5.Size = new System.Drawing.Size(100, 16);
			this.Label5.TabIndex = 2;
			this.Label5.Text = "Select a Food";
			// 
			// GroupBox1
			// 
			this.GroupBox1.Controls.Add(this.Label8);
			this.GroupBox1.Controls.Add(this.txFoodPrice);
			this.GroupBox1.Controls.Add(this.Label10);
			this.GroupBox1.Controls.Add(this.btSaveFood);
			this.GroupBox1.Controls.Add(this.txFoodName);
			this.GroupBox1.Controls.Add(this.btDeleteFood);
			this.GroupBox1.Location = new System.Drawing.Point(16, 132);
			this.GroupBox1.Name = "GroupBox1";
			this.GroupBox1.Size = new System.Drawing.Size(520, 360);
			this.GroupBox1.TabIndex = 0;
			this.GroupBox1.TabStop = false;
			this.GroupBox1.Text = "Edit Food";
			// 
			// Label8
			// 
			this.Label8.Location = new System.Drawing.Point(16, 68);
			this.Label8.Name = "Label8";
			this.Label8.Size = new System.Drawing.Size(40, 23);
			this.Label8.TabIndex = 34;
			this.Label8.Text = "Price:";
			this.Label8.TextAlign = System.Drawing.ContentAlignment.TopRight;
			// 
			// txFoodPrice
			// 
			this.txFoodPrice.Location = new System.Drawing.Point(64, 64);
			this.txFoodPrice.Name = "txFoodPrice";
			this.txFoodPrice.Size = new System.Drawing.Size(176, 20);
			this.txFoodPrice.TabIndex = 30;
			this.txFoodPrice.Text = "";
			// 
			// Label10
			// 
			this.Label10.Location = new System.Drawing.Point(16, 36);
			this.Label10.Name = "Label10";
			this.Label10.Size = new System.Drawing.Size(40, 23);
			this.Label10.TabIndex = 31;
			this.Label10.Text = "Name:";
			this.Label10.TextAlign = System.Drawing.ContentAlignment.TopRight;
			// 
			// btSaveFood
			// 
			this.btSaveFood.Location = new System.Drawing.Point(24, 108);
			this.btSaveFood.Name = "btSaveFood";
			this.btSaveFood.Size = new System.Drawing.Size(64, 20);
			this.btSaveFood.TabIndex = 31;
			this.btSaveFood.Text = "Save";
			this.btSaveFood.Click += new System.EventHandler(this.btSaveFood_Click);
			// 
			// txFoodName
			// 
			this.txFoodName.Location = new System.Drawing.Point(64, 32);
			this.txFoodName.Name = "txFoodName";
			this.txFoodName.Size = new System.Drawing.Size(176, 20);
			this.txFoodName.TabIndex = 29;
			this.txFoodName.Text = "";
			// 
			// btDeleteFood
			// 
			this.btDeleteFood.Location = new System.Drawing.Point(440, 112);
			this.btDeleteFood.Name = "btDeleteFood";
			this.btDeleteFood.Size = new System.Drawing.Size(64, 20);
			this.btDeleteFood.TabIndex = 32;
			this.btDeleteFood.Text = "Delete";
			this.btDeleteFood.Click += new System.EventHandler(this.btDeleteFood_Click);
			// 
			// tpStepFour
			// 
			this.tpStepFour.Controls.Add(this.Label16);
			this.tpStepFour.Controls.Add(this.txStepFourEmail);
			this.tpStepFour.Controls.Add(this.numFoodPriceUpper);
			this.tpStepFour.Controls.Add(this.numFoodPriceLower);
			this.tpStepFour.Controls.Add(this.Label7);
			this.tpStepFour.Controls.Add(this.Label9);
			this.tpStepFour.Controls.Add(this.lvLunchOrders);
			this.tpStepFour.Controls.Add(this.Label12);
			this.tpStepFour.Controls.Add(this.btSearchLunchOrders);
			this.tpStepFour.Controls.Add(this.Label13);
			this.tpStepFour.Location = new System.Drawing.Point(4, 22);
			this.tpStepFour.Name = "tpStepFour";
			this.tpStepFour.Size = new System.Drawing.Size(552, 511);
			this.tpStepFour.TabIndex = 3;
			this.tpStepFour.Text = "Joins";
			this.tpStepFour.Visible = false;
			// 
			// Label16
			// 
			this.Label16.BackColor = System.Drawing.Color.LightSteelBlue;
			this.Label16.BorderStyle = System.Windows.Forms.BorderStyle.FixedSingle;
			this.Label16.ForeColor = System.Drawing.Color.Navy;
			this.Label16.Location = new System.Drawing.Point(12, 12);
			this.Label16.Name = "Label16";
			this.Label16.Size = new System.Drawing.Size(528, 40);
			this.Label16.TabIndex = 47;
			this.Label16.Text = "Example 4. This example demonstrates an Inner Join over three database tables - L" +
				"unchOrder, Student and Food. Enter a Student\'s email (optional), select a Food p" +
				"rice range, and click Go.";
			this.Label16.TextAlign = System.Drawing.ContentAlignment.MiddleCenter;
			// 
			// txStepFourEmail
			// 
			this.txStepFourEmail.Location = new System.Drawing.Point(60, 92);
			this.txStepFourEmail.Name = "txStepFourEmail";
			this.txStepFourEmail.Size = new System.Drawing.Size(176, 20);
			this.txStepFourEmail.TabIndex = 46;
			this.txStepFourEmail.Text = "";
			// 
			// numFoodPriceUpper
			// 
			this.numFoodPriceUpper.DecimalPlaces = 2;
			this.numFoodPriceUpper.Location = new System.Drawing.Point(140, 124);
			this.numFoodPriceUpper.Name = "numFoodPriceUpper";
			this.numFoodPriceUpper.Size = new System.Drawing.Size(60, 20);
			this.numFoodPriceUpper.TabIndex = 45;
			this.numFoodPriceUpper.Value = new System.Decimal(new int[] {
																			50,
																			0,
																			0,
																			0});
			// 
			// numFoodPriceLower
			// 
			this.numFoodPriceLower.DecimalPlaces = 2;
			this.numFoodPriceLower.Location = new System.Drawing.Point(60, 124);
			this.numFoodPriceLower.Name = "numFoodPriceLower";
			this.numFoodPriceLower.Size = new System.Drawing.Size(56, 20);
			this.numFoodPriceLower.TabIndex = 44;
			// 
			// Label7
			// 
			this.Label7.Location = new System.Drawing.Point(120, 128);
			this.Label7.Name = "Label7";
			this.Label7.Size = new System.Drawing.Size(16, 16);
			this.Label7.TabIndex = 43;
			this.Label7.Text = "to";
			// 
			// Label9
			// 
			this.Label9.Location = new System.Drawing.Point(12, 128);
			this.Label9.Name = "Label9";
			this.Label9.Size = new System.Drawing.Size(40, 16);
			this.Label9.TabIndex = 42;
			this.Label9.Text = "Price:";
			this.Label9.TextAlign = System.Drawing.ContentAlignment.TopRight;
			// 
			// lvLunchOrders
			// 
			this.lvLunchOrders.Columns.AddRange(new System.Windows.Forms.ColumnHeader[] {
																							this.chLunchOrderDate,
																							this.chLunchOrderStudent,
																							this.cbLunchOrderEmail,
																							this.chLunchOrderFood,
																							this.chLunchOrderQuantity,
																							this.chLunchOrderFoodPrice,
																							this.chLunchOrderTotal});
			this.lvLunchOrders.Location = new System.Drawing.Point(12, 200);
			this.lvLunchOrders.Name = "lvLunchOrders";
			this.lvLunchOrders.Size = new System.Drawing.Size(528, 292);
			this.lvLunchOrders.TabIndex = 41;
			this.lvLunchOrders.View = System.Windows.Forms.View.Details;
			// 
			// chLunchOrderDate
			// 
			this.chLunchOrderDate.Text = "Date";
			this.chLunchOrderDate.Width = 69;
			// 
			// chLunchOrderStudent
			// 
			this.chLunchOrderStudent.Text = "Student";
			this.chLunchOrderStudent.Width = 72;
			// 
			// cbLunchOrderEmail
			// 
			this.cbLunchOrderEmail.Text = "Email";
			this.cbLunchOrderEmail.Width = 83;
			// 
			// chLunchOrderFood
			// 
			this.chLunchOrderFood.Text = "Food";
			this.chLunchOrderFood.Width = 104;
			// 
			// chLunchOrderQuantity
			// 
			this.chLunchOrderQuantity.Text = "Quantity";
			this.chLunchOrderQuantity.Width = 68;
			// 
			// chLunchOrderFoodPrice
			// 
			this.chLunchOrderFoodPrice.Text = "Food Price";
			this.chLunchOrderFoodPrice.Width = 75;
			// 
			// chLunchOrderTotal
			// 
			this.chLunchOrderTotal.Text = "Total";
			this.chLunchOrderTotal.Width = 89;
			// 
			// Label12
			// 
			this.Label12.Location = new System.Drawing.Point(12, 96);
			this.Label12.Name = "Label12";
			this.Label12.Size = new System.Drawing.Size(40, 23);
			this.Label12.TabIndex = 32;
			this.Label12.Text = "Email:";
			this.Label12.TextAlign = System.Drawing.ContentAlignment.TopRight;
			// 
			// btSearchLunchOrders
			// 
			this.btSearchLunchOrders.Location = new System.Drawing.Point(16, 160);
			this.btSearchLunchOrders.Name = "btSearchLunchOrders";
			this.btSearchLunchOrders.Size = new System.Drawing.Size(64, 24);
			this.btSearchLunchOrders.TabIndex = 31;
			this.btSearchLunchOrders.Text = "Go";
			this.btSearchLunchOrders.Click += new System.EventHandler(this.btSearchLunchOrders_Click);
			// 
			// Label13
			// 
			this.Label13.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Bold, System.Drawing.GraphicsUnit.Point, ((System.Byte)(0)));
			this.Label13.Location = new System.Drawing.Point(12, 68);
			this.Label13.Name = "Label13";
			this.Label13.Size = new System.Drawing.Size(144, 16);
			this.Label13.TabIndex = 30;
			this.Label13.Text = "Search Lunch Orders";
			// 
			// Form1
			// 
			this.AutoScaleBaseSize = new System.Drawing.Size(5, 13);
			this.ClientSize = new System.Drawing.Size(560, 537);
			this.Controls.Add(this.TabControl1);
			this.Icon = ((System.Drawing.Icon)(resources.GetObject("$this.Icon")));
			this.Menu = this.mainMenu1;
			this.Name = "Form1";
			this.Text = "BizBlox C# Examples";
			this.TabControl1.ResumeLayout(false);
			this.tpStepOne.ResumeLayout(false);
			this.tpStepTwo.ResumeLayout(false);
			((System.ComponentModel.ISupportInitialize)(this.numAgeUpper)).EndInit();
			((System.ComponentModel.ISupportInitialize)(this.numAgeLower)).EndInit();
			this.tpStepThree.ResumeLayout(false);
			this.GroupBox1.ResumeLayout(false);
			this.tpStepFour.ResumeLayout(false);
			((System.ComponentModel.ISupportInitialize)(this.numFoodPriceUpper)).EndInit();
			((System.ComponentModel.ISupportInitialize)(this.numFoodPriceLower)).EndInit();
			this.ResumeLayout(false);

		}
		#endregion


		#region '"Setup and Menu"' 
        
		private void setupData() 
		{
			try 
			{ 
				StudentCollection sColl = new StudentCollection(); 
				sColl.FindAll(); 
				if ( sColl.Count == 0 ) 
				{ 
					Setup.CreateDataSet(); 
				} 
				this.BindFoodTypes(); 
			} 
			catch ( Exception ex ) 
			{ 
				MessageBox.Show( "BizBlox was unable to connect to the database. Please check the settings in the app.config file." + "\r\n" + "\r\n" + "Connection string used: " + "\r\n" + DSNManager.GetConnectionString() + ", Exception: " + ex.ToString(), "Could not connect to database", MessageBoxButtons.OK, MessageBoxIcon.Error ); 
				Application.Exit(); 
			} 
		}

        private void mnuResetData_Click(object sender, System.EventArgs e)
		{
			Cursor.Current = Cursors.WaitCursor; 
			Setup.ClearDataSet(); 
			Setup.CreateDataSet(); 
			this.BindFoodTypes(); 
			Cursor.Current = Cursors.Default; 		
		}
        
        
		private void mnuAbout_Click( System.Object sender, System.EventArgs e ) 
		{ 
			About a = new About(); 
			a.Show(); 
		} 
        
        
		#endregion 
        
        
		#region '"Simple Binding"' 
        
		private void btLoadStudents_Click( System.Object sender, System.EventArgs e ) 
		{ 
			this.LoadStudents(); 
		} 
        
        
		private void LoadStudents() 
		{ 
			Cursor.Current = Cursors.WaitCursor; 
			this.lvStudents.Items.Clear(); 
			StudentCollection sColl = new StudentCollection(); 
			sColl.FindAll(); 
			for ( int i=0; i <= sColl.Count - 1; i++ ) 
			{ 
				Student sObj = sColl[i]; 
				ListViewItem lvi = new ListViewItem( new string[] { sObj.Name, sObj.Email, sObj.Age.ToString() } ); 
				this.lvStudents.Items.Add( lvi ); 
			} 
			Cursor.Current = Cursors.Default; 
		} 
        
        
		#endregion 
        

		#region '"Searching"' 
        
		private void btSearchStudents_Click( System.Object sender, System.EventArgs e ) 
		{ 
			Cursor.Current = Cursors.WaitCursor; 
			this.lvSearchStudents.Items.Clear(); 
			StudentCollection sColl = new StudentCollection(); 
			sColl.FindByNameEmailAge( txSearchTermStudents.Text, txSearchByEmail.Text, (int)this.numAgeLower.Value, (int)this.numAgeUpper.Value ); 
			for ( int i=0; i <= sColl.Count - 1; i++ ) 
			{ 
				Student sObj = sColl[i]; 
				ListViewItem lvi = new ListViewItem( new string[] { sObj.Name, sObj.Email, sObj.Age.ToString() } ); 
				this.lvSearchStudents.Items.Add( lvi ); 
			} 
			Cursor.Current = Cursors.Default; 
		} 
        
        
		#endregion 
        

		#region '"Editing"' 
                
		private void BindFoodTypes() 
		{ 
			FoodCollection fColl = new FoodCollection(); 
			fColl.FindAll(); 
			fColl.BindDataSource (Food.Columns.Name,this.cbFood,"Add New Food...");
			this.DoFoodSelected();
		} 
        
        
		private void cbFood_SelectedIndexChanged( System.Object sender, System.EventArgs e ) 
		{ 
			this.DoFoodSelected();
		} 
        
        
		private void DoFoodSelected() 
		{
			try 
			{
				if (this.cbFood.SelectedValue.ToString() =="-1") 
				{
					this.txFoodName.Text="";
					this.txFoodPrice.Text="";
					this.btDeleteFood.Visible=false;
				}
				else 
				{
					Guid foodId = new Guid( this.cbFood.SelectedValue.ToString() ); 
					this.LoadFood( foodId ); 
					this.btDeleteFood.Visible=true;
				}
			}
			catch (Exception ex) 
			{
                Console.WriteLine(ex.ToString());                
			}
		}					

  		private void btDeleteFood_Click( System.Object sender, System.EventArgs e ) 
		{ 
			Cursor.Current = Cursors.WaitCursor; 
			DialogResult dr = MessageBox.Show( "Are you sure you want to delete this food, and all lunch orders involving this food?", "Confirm deletion", MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question, MessageBoxDefaultButton.Button1 ); 
			if (dr == DialogResult.Yes) {
				Guid foodId = new Guid( this.cbFood.SelectedValue.ToString() ); 
				LunchOrderCollection loColl = new LunchOrderCollection(); 
				loColl.FindByFood( foodId ); 
				loColl.Delete(); 
				DOFactory f = new DOFactory( typeof( Food ) ); 
				Food fObj = (Food) f.Retrieve( foodId ); 
				fObj.Delete(); 
				this.BindFoodTypes(); 
			}
			Cursor.Current = Cursors.Default; 
		} 
        
        
		private void btSaveFood_Click( System.Object sender, System.EventArgs e ) 
		{ 
			Cursor.Current = Cursors.WaitCursor; 
			
			// Validate input data
			double price = 0; 
			try 
			{ 
				price = double.Parse( this.txFoodPrice.Text ); 
			} 
			catch ( Exception ex ) 
			{ 
				MessageBox.Show( "Please enter a valid price." );
                Console.WriteLine(ex.ToString());
				return ; 
			} 

			// Create or retrieve the Food
			DOFactory f = new DOFactory( typeof( Food ) ); 
			Food fObj;
			string message="";
			if ((string)this.cbFood.SelectedValue=="-1") 
			{
				fObj=(Food)f.Create();
				message=this.txFoodName.Text + " added!";
			}
			else 
			{
				Guid foodId = new Guid( this.cbFood.SelectedValue.ToString() ); 
				fObj = (Food)f.Retrieve( foodId ); 
				message=this.txFoodName.Text + " updated!";
			}
			// Update the Food properties, and Save
			fObj.Name = this.txFoodName.Text; 
			fObj.Price = price; 
			fObj.Save();

			// Reset the view
			this.BindFoodTypes(); 
			this.cbFood.SelectedValue = fObj.FoodID.ToString(); 
			DoFoodSelected();
			MessageBox.Show(message);
			Cursor.Current = Cursors.Default; 
		} 
        

		private void LoadFood( Guid foodId ) 
		{ 
			DOFactory f = new DOFactory( typeof( Food ) ); 
			Food fObj = (Food)f.Retrieve( foodId ); 
			this.txFoodName.Text = fObj.Name; 
			this.txFoodPrice.Text = fObj.Price.ToString( "0.00" ); 
		} 
                
		#endregion 
        
        
		#region '"Joins"' 
        
		private void btSearchLunchOrders_Click( System.Object sender, System.EventArgs e ) 
		{ 
			Cursor.Current = Cursors.WaitCursor; 
			this.lvLunchOrders.Items.Clear(); 
			LunchOrderCollection loColl = new LunchOrderCollection(); 
			loColl.FindByEmailAndPrice( this.txStepFourEmail.Text, (double) this.numFoodPriceLower.Value, (double) this.numFoodPriceUpper.Value ); 
			for ( int i=0; i <= loColl.Count - 1; i++ ) 
			{ 
				LunchOrder loObj = loColl[i]; 
				Food fObj = loObj.GetByFoodID(); 
				Student sObj = loObj.GetByStudentID(); 
				string total = ( loObj.Quantity * fObj.Price ).ToString( "$0.00" ); 
				ListViewItem lvi = new ListViewItem( new string[] { loObj.dt_OrderDate.ToShortDateString(), sObj.Name, sObj.Email, fObj.Name, loObj.Quantity.ToString(), fObj.Price.ToString( "$0.00" ), total } ); 
				this.lvLunchOrders.Items.Add( lvi ); 
			} 
			Cursor.Current = Cursors.Default; 
		}                 
		#endregion 


	}


}